#pragma once

#include"config.h"
#ifndef FILECONTROL_
#define FILECONTROL_

#include<filesystem>
namespace fs = std::filesystem;

enum FILETYPE
{
    REGULAR,
    DIR,
    SYMBOL,
    NONE,
    NOTFOUND,
    BLOCK,
    SOCKET,
    FIFO,
    CHAR,
    JUNC
};

/*��ʾ���ѹ��ܵĵ���*/
enum SHOWTYPE {
    TEXT,
    DIALOG
};



inline void DeleFile(const std::string& filePath) {
    Terminal_Info << filePath;
}


inline void CreateFile(const std::string& filePath) {

}
inline ulint SizeOfPath(const fs::path& fPath) {
    if (fs::exists(fPath)) {
        ulint fSize = fs::file_size(fPath);
        return fSize;
    }
    return 0;
}

inline ulint SizeOfFile(const std::string& filePath) {

    fs::path fPath = fs::path(filePath);

    if (0 == SizeOfPath(fPath)) {
        Terminal_Warn << filePath << "is not exists!";
    }
    return 0;
}



inline FILETYPE TypeOfFile(std::string& filepath) {
    const fs::path fPath = fs::path(filepath);
    if (!fs::exists(fPath))
    {
        return NONE;
    }

    if (fs::is_symlink(fPath))
    {
        return SYMBOL;
    }

    fs::file_status fStatus = fs::status(fPath);
    switch (fStatus.type()) {
    case fs::file_type::none:
        return NONE;
    case fs::file_type::not_found:
        return NOTFOUND;
    case fs::file_type::directory:
        return DIR;
    case fs::file_type::symlink:
        return SYMBOL;
    case fs::file_type::block:
        return BLOCK;
    case fs::file_type::socket:
        return SOCKET;
    case fs::file_type::fifo:
        return FIFO;
    case fs::file_type::character:
        return CHAR;
    case fs::file_type::unknown:
    case fs::file_type::regular:
        return REGULAR;
    // case fs::file_type::junction:
    //     return JUNC;
    }
    return REGULAR;
}



#endif
